package thread.state;

public class SynchrounizedThreadStateTest {
    static Object object = new Object();
    static SyncThread mThread0 = new SyncThread();
    static SyncThread mThread1 = new SyncThread();

    public static void main(String[] args) {
        mThread0.setName("thread0");

        mThread0.start();

        System.out.println("thread0 after start() state is " + mThread0.getState().name());

        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        System.out.println("thread0 after start() 100ms state is " + mThread0.getState().name());

        mThread1.start();

        System.out.println("thread1 after start() state is " + mThread1.getState().name());

        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        System.out.println("thread1 after start() 100ms state is " + mThread1.getState().name());
    }

    static class SyncThread extends Thread {
        @Override
        public void run() {
            super.run();

            synchronized (object) {
//                try {
////                    object.wait();
//                } catch (InterruptedException e) {
//                    e.printStackTrace();
//                }

                for (; ; ) {
                    // do nothing
                }
            }
        }
    }
}